<?php
/**
 * 权限菜单
 * UserModel: LLw
 * Date: 2020-01-07
 * Time: 14:33
 */
namespace app\caidongweb\controller;

use think\Request;

/**
 * Class Rule
 * 权限菜单类
 * @package app\caidongweb\controller
 */
class Rule extends BaseController
{
    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->Rule = new \app\caidongweb\model\Rule();
    }

    /**
     * 首页内容显示
     * @return \think\response\View
     */
    public function Index()
    {
        $list = $this->Rule->ruleList();
        $this->assign('list',$list);
        return view();
    }

    /**
     * 修改规则
     * @return array|false|\PDOStatement|string|\think\Model|\think\response\View
     */
    public function edit()
    {
        if(input('post.')){
            $res = $this->Rule->getEdit();
            return $res;
        }else{
            $auth_rule = $this->Rule->getEdit();
            $rule_list = $this->Rule->getList();
            $this->assign('list',$auth_rule);
            $this->assign('rule',$rule_list);
            return view();
        }
    }

    /**
     * 添加规则
     * @return array|false|\PDOStatement|string|\think\Model|\think\response\View
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function add()
    {
        if(input('post.')){
            $res = $this->Rule->getEdit();
            return $res;
        }else{
            $rule = $this->Rule->getList();
            $this->assign('rule',$rule);
            return view();
        }
    }

    public function delList()
    {
        $res = $this->Rule->delList();
        return $res;
    }
}